package com.efast.dmom.mgmt.service.mes.impl;
import java.util.List;
import java.util.Map;

import com.efast.cafe.framework.bean.ResultBean;
import com.efast.dmom.mgmt.dao.mes.TrBasPdPlRouteDao;
import com.efast.dmom.mgmt.entity.mes.TrBasPdPlRoute;
import com.efast.dmom.mgmt.service.mes.TrBasPdPlRouteService;
import com.efast.dmom.mgmt.utils.Assist;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class TrBasPdPlRouteServiceImpl implements TrBasPdPlRouteService{
    @Autowired
    private TrBasPdPlRouteDao trBasPdPlRouteDao;
    @Override
    public long getTrBasPdPlRouteRowCount(Assist assist){
        return trBasPdPlRouteDao.getTrBasPdPlRouteRowCount(assist);
    }
    @Override
    public List<TrBasPdPlRoute> selectTrBasPdPlRoute(Assist assist){
        return trBasPdPlRouteDao.selectTrBasPdPlRoute(assist);
    }
    @Override
    public TrBasPdPlRoute selectTrBasPdPlRouteByObj(TrBasPdPlRoute obj){
        return trBasPdPlRouteDao.selectTrBasPdPlRouteByObj(obj);
    }
    @Override
    public TrBasPdPlRoute selectTrBasPdPlRouteById(Integer id){
        return trBasPdPlRouteDao.selectTrBasPdPlRouteById(id);
    }
    @Override
    public int insertTrBasPdPlRoute(TrBasPdPlRoute value){
        return trBasPdPlRouteDao.insertTrBasPdPlRoute(value);
    }
    @Override
    public int insertNonEmptyTrBasPdPlRoute(TrBasPdPlRoute value){
        return trBasPdPlRouteDao.insertNonEmptyTrBasPdPlRoute(value);
    }
    @Override
    public int insertTrBasPdPlRouteByBatch(List<TrBasPdPlRoute> value){
        return trBasPdPlRouteDao.insertTrBasPdPlRouteByBatch(value);
    }
    @Override
    public int deleteTrBasPdPlRouteById(Integer id){
        return trBasPdPlRouteDao.deleteTrBasPdPlRouteById(id);
    }
    @Override
    public int deleteTrBasPdPlRoute(Assist assist){
        return trBasPdPlRouteDao.deleteTrBasPdPlRoute(assist);
    }
    @Override
    public int updateTrBasPdPlRouteById(TrBasPdPlRoute enti){
        return trBasPdPlRouteDao.updateTrBasPdPlRouteById(enti);
    }
    @Override
    public int updateTrBasPdPlRoute(TrBasPdPlRoute value, Assist assist){
        return trBasPdPlRouteDao.updateTrBasPdPlRoute(value,assist);
    }
    @Override
    public int updateNonEmptyTrBasPdPlRouteById(TrBasPdPlRoute enti){
        return trBasPdPlRouteDao.updateNonEmptyTrBasPdPlRouteById(enti);
    }
    @Override
    public int updateNonEmptyTrBasPdPlRoute(TrBasPdPlRoute value, Assist assist){
        return trBasPdPlRouteDao.updateNonEmptyTrBasPdPlRoute(value,assist);
    }
    
    @Override
    public TrBasPdPlRoute getByPartNo(String partNoVersion,String lineName) {
    	return trBasPdPlRouteDao.getByPartNo(partNoVersion,lineName);
    }

    public TrBasPdPlRouteDao getTrBasPdPlRouteDao() {
        return this.trBasPdPlRouteDao;
    }

    public void setTrBasPdPlRouteDao(TrBasPdPlRouteDao trBasPdPlRouteDao) {
        this.trBasPdPlRouteDao = trBasPdPlRouteDao;
    }
	@Override
	public ResultBean selectTrBasPdPlRouteByRoutidPartid(Integer partId, Integer routeId) {
		ResultBean resultBean = new ResultBean(false,"查询失败");
		Assist assist = new Assist();
		assist.setRequires(Assist.andEq("part_id", partId));
		assist.setRequires(Assist.andEq("route_id", routeId));
		List<TrBasPdPlRoute> selectTrBasPdPlRoute = trBasPdPlRouteDao.selectTrBasPdPlRoute(assist);
		if (selectTrBasPdPlRoute.size()==1) {
			TrBasPdPlRoute trBasPdPlRoute = selectTrBasPdPlRoute.get(0);
			Integer lineId = trBasPdPlRoute.getLineId();
			resultBean.setSuccess(true);
			resultBean.setObject(lineId);
			resultBean.setMessage("查询成功！");
		}
		return resultBean;
	}
	@Override
	public ResultBean selectOperationCountByTrBasPdPlRoute() {
		ResultBean resultBean = new ResultBean();
		List<Map<String, Integer>> list = trBasPdPlRouteDao.selectOperationCountByTrBasPdPlRoute();
		if (list.size() == 0) {
			resultBean.setSuccess(false);
		} else {
			resultBean.setSuccess(true);
			resultBean.setObject(list);
		}
		return resultBean;
	}

}